<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script>

$(function() {
		$( "input:submit, a, button", ".register" ).button();
		$( "a", ".demo" ).click(function() { return false; });
	});
	$(function() {
		function log( message ) {
			$( "<div/>" ).text( message ).prependTo( "#log" );
			$( "#log" ).scrollTop( 0 );
		}
		
	$( "#city" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: "http://ws.geonames.org/searchJSON",
				dataType: "jsonp",
				data: {
					featureClass: "P",
					style: "full",
					maxRows: 12,
					name_startsWith: request.term
				},
				success: function( data ) {
					response( $.map( data.geonames, function( item ) {
						return {
							label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
							value: item.name
						}
					}));
				}
			});
		},
		minLength: 2,
		select: function( event, ui ) {
			log( ui.item ?
				"Selected: " + ui.item.label :
				"Nothing selected, input was " + this.value);
		},
		open: function() {
			$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
		},
		close: function() {
			$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
		}
	});
});
</script>
<div class="register">
	<c:if test="${mode != 'change'}">
		<div class="hinweis">Hier kannst du dich für unseren Service
			kostenlos und unverbindlich registrieren. Alle Felder sind
			Pflichtfelder.</div>
	</c:if>
	<form method="post" action="SaveUser.html">
		<table class="editing">
			<tbody>
				<tr>
					<td><input type="hidden" name="id"
						value='<c:out value="${person.getId()}"/>' /> <c:choose>
							<c:when test='${person.getNachname() == "" && errormsg != ""}'>
								<span style="color: red">Name:</span>
							</c:when>
							<c:otherwise>
					        Name:
					    </c:otherwise>
						</c:choose></td>
					<td><input type="text" name="name" size="30"
						value='<c:out value="${person.getNachname()}"/>' /></td>
				</tr>
				<tr>
					<td><c:choose>
							<c:when test='${person.getVorname() == "" && errormsg != ""}'>
								<span style="color: red">Vorname:</span>
							</c:when>
							<c:otherwise>
					        Vorname:
					    </c:otherwise>
						</c:choose></td>
					<td><input type="text" name="vname" size="30"
						value='<c:out value="${person.getVorname()}"/>' /></td>
				</tr>
				<tr>
					<td><c:choose>
							<c:when test='${person.getAdresse() == "" && errormsg != ""}'>
								<span style="color: red">Adresse:</span>
							</c:when>
							<c:otherwise>
					        Adresse:
					    </c:otherwise>
						</c:choose></td>
					<td><input type="text" name="adresse" size="30"
						value='<c:out value="${person.getAdresse()}"/>' /></td>
				</tr>
				<tr>
					<td><c:choose>
							<c:when test='${person.getPLZ() == "" && errormsg != ""}'>
								<span style="color: red">PLZ:</span>
							</c:when>
							<c:otherwise>
					        PLZ:
					    </c:otherwise>
						</c:choose></td>
					<td><input type="text" name="plz" size="30"
						value='<c:out value="${person.getPLZ()}"/>' /></td>
				</tr>
				<tr>
					<td><c:choose>
							<c:when test='${person.getOrt() == "" && errormsg != ""}'>
								<span style="color: red">Ort:</span>
							</c:when>
							<c:otherwise>
					        Ort:
					    </c:otherwise>
						</c:choose></td>
					<td><input type="text" name="ort" size="30" id="city"
						value='<c:out value="${person.getOrt()}"/>' /></td>
				</tr>
				<tr>
					<td><c:choose>
							<c:when
								test='${person.getEMail() == "" && errormsg != "" || errEmail == "1"}'>
								<span style="color: red">E-Mail:</span>
							</c:when>
							<c:otherwise>
					        E-Mail:
					    </c:otherwise>
						</c:choose></td>
					<td><c:choose>
							<c:when test='${mode == "change"}'>
								<input type="text" name="email" readonly='readonly' size="30"
									value='<c:out value="${person.getEMail()}"/>' />
								<br>E-Mail kann nicht abgeaendert werden.<br>
							</c:when>
							<c:otherwise>
								<input type="text" name="email" size="30"
									value='<c:out value="${person.getEMail()}"/>' />
							</c:otherwise>
						</c:choose></td>
				</tr>
				<tr>
					<td>Status Couch:</td>
					<td><select name="stateCouch">
							<c:forEach items="${typStati}" var="typStatus">
								<c:choose>
									<c:when
										test='${person.getStateCouch().getId() == typStatus.getId()}'>
										<option value="${typStatus.getId()}" selected="selected">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:when>
									<c:otherwise>
										<option value="${typStatus.getId()}">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td>Status Internet:</td>
					<td><select name="stateInternet">
							<c:forEach items="${typStati}" var="typStatus">
								<c:choose>
									<c:when
										test='${person.getStateInternet().getId() == typStatus.getId()}'>
										<option value="${typStatus.getId()}" selected="selected">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:when>
									<c:otherwise>
										<option value="${typStatus.getId()}">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td>Status Stadtführung:</td>
					<td><select name="stateZeigeStadt">
							<c:forEach items="${typStati}" var="typStatus">
								<c:choose>
									<c:when
										test='${person.getStateZeigeStadt().getId() == typStatus.getId()}'>
										<option value="${typStatus.getId()}" selected="selected">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:when>
									<c:otherwise>
										<option value="${typStatus.getId()}">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td>Status Parkplatz:</td>
					<td><select name="stateParkplatz">
							<c:forEach items="${typStati}" var="typStatus">
								<c:choose>
									<c:when
										test='${person.getStateParkplatz().getId() == typStatus.getId()}'>
										<option value="${typStatus.getId()}" selected="selected">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:when>
									<c:otherwise>
										<option value="${typStatus.getId()}">
											<c:out value="${typStatus.getBezeichnung()}"></c:out>
										</option>
									</c:otherwise>
								</c:choose>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td><c:if test="${isLogUserAdmin == true}">
							ist Admin
						</c:if></td>
					<td><c:choose>
							<c:when test='${isLogUserAdmin == true}'>
								<c:choose>
									<c:when test='${person.getIsAdmin() == true}'>
										<INPUT TYPE="checkbox" NAME="isAdmin"
											value='<c:out value="${person.getIsAdmin()}"/>' CHECKED />
									</c:when>
									<c:otherwise>
										<INPUT TYPE="checkbox" NAME="isAdmin"
											value='<c:out value="${person.getIsAdmin()}"/>' />
									</c:otherwise>
								</c:choose>
							</c:when>
							<c:otherwise>
								<input type="hidden" name="isAdmin"
									value='<c:out value="${person.getIsAdmin()}"/>' />
							</c:otherwise>
						</c:choose></td>
				</tr>
				<tr class="submit">
					<td colspan="2" align="left"><br>
					<br>
					<input type="submit" value="Speichern" /></td>
				</tr>
				<tr>
					<td></td>
					<td><br></br>
					<br></br> <c:out value="${msg}" /><br></br></td>
				</tr>
			</tbody>
		</table>
	</form>
</div>

<!--  
<c:if test="${!empty msg}">
	<div title="Nachricht"
		style="height: 150px; min-height: 130px; width: 400px;"
		class="ui-dialog-content ui-widget-content" id="dialog">
		<p>
			<span class="ui-icon ui-icon-info"
				style="float: left; margin-right: .3em;"></span>
			<c:out value="${msg}" />
		</p>
	</div>
</c:if>
 -->
<c:if test="${!empty errormsg}">
	<div title="Fehler" class="ui-dialog-content ui-widget-content fehler" id="dialog">
		<p>
			<span class="ui-icon ui-icon-alert"
				style="float: left; margin-right: .3em;"></span>
			<c:out value="${errormsg}" />
		</p>
	</div>
</c:if>
